package com.taobao.txc.client.aop;

import com.taobao.txc.client.aop.annotation.TxcTransaction;
import com.taobao.txc.common.LoggerInit;
import com.taobao.txc.common.LoggerWrap;
import com.taobao.txc.common.config.o;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class b
  implements MethodInterceptor
{
  private static final LoggerWrap b = LoggerInit.logger;
  private final com.taobao.txc.client.b.b c = new com.taobao.txc.client.b.b();
  private volatile HashMap<Object, TxcTransaction> d = new HashMap();
  protected static final TxcTransaction a = new e();
  
  public b(List<a> paramList)
  {
    Iterator localIterator = paramList.iterator();
    while (localIterator.hasNext())
    {
      a locala = (a)localIterator.next();
      b.info("add:" + locala.b());
      this.d.put(a(locala.b()), locala.a());
    }
  }
  
  public Object invoke(MethodInvocation paramMethodInvocation)
  {
    TxcTransaction localTxcTransaction = a(paramMethodInvocation);
    if (localTxcTransaction != a)
    {
      if (o.a().b(com.taobao.txc.a.b.g.f())) {
        return paramMethodInvocation.proceed();
      }
      if (localTxcTransaction.type() == com.taobao.txc.client.aop.annotation.a.b) {
        return this.c.a(new c(this, paramMethodInvocation), localTxcTransaction.effectiveTime());
      }
      if (localTxcTransaction.type() == com.taobao.txc.client.aop.annotation.a.a) {
        return this.c.a(new d(this, paramMethodInvocation), localTxcTransaction.timeout(), com.taobao.txc.common.util.c.g.c(localTxcTransaction.appName()), com.taobao.txc.common.util.c.g.a(paramMethodInvocation.getMethod()));
      }
    }
    return paramMethodInvocation.proceed();
  }
  
  private static String a(Method paramMethod)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    String str = paramMethod.getName();
    Class[] arrayOfClass1 = paramMethod.getParameterTypes();
    localStringBuilder.append(str);
    localStringBuilder.append("(");
    int i = 0;
    for (Class localClass : arrayOfClass1)
    {
      localStringBuilder.append(localClass.getName());
      i++;
      if (i < arrayOfClass1.length) {
        localStringBuilder.append(",");
      }
    }
    localStringBuilder.append(")");
    return localStringBuilder.toString();
  }
  
  protected TxcTransaction a(MethodInvocation paramMethodInvocation)
  {
    TxcTransaction localTxcTransaction = (TxcTransaction)this.d.get(paramMethodInvocation.getMethod());
    if (localTxcTransaction == null) {
      synchronized (this)
      {
        localTxcTransaction = (TxcTransaction)this.d.get(paramMethodInvocation.getMethod());
        if (localTxcTransaction == null)
        {
          String str = a(paramMethodInvocation.getMethod());
          localTxcTransaction = (TxcTransaction)this.d.get(str);
          if (localTxcTransaction == null) {
            localTxcTransaction = a;
          }
          HashMap localHashMap = new HashMap();
          localHashMap.putAll(this.d);
          localHashMap.remove(str);
          localHashMap.put(paramMethodInvocation.getMethod(), localTxcTransaction);
          this.d = localHashMap;
        }
      }
    }
    if (b.c()) {
      if (localTxcTransaction != a) {
        b.debug("Y:" + paramMethodInvocation.getMethod());
      } else {
        b.debug("N:" + paramMethodInvocation.getMethod());
      }
    }
    return localTxcTransaction;
  }
}


/* Location:           C:\Users\ibm\Downloads\txc-yun-sample (1)\txc-yun-sample\lib\txc-client-2.0.72.jar
 * Qualified Name:     com.taobao.txc.client.aop.b
 * JD-Core Version:    0.7.0.1
 */